/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package transervfx.Dato.Entidad;

import java.io.Serializable;
import javafx.beans.property.adapter.JavaBeanIntegerProperty;
import javafx.beans.property.adapter.JavaBeanIntegerPropertyBuilder;
import javafx.beans.property.adapter.JavaBeanStringProperty;
import javafx.beans.property.adapter.JavaBeanStringPropertyBuilder;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.hibernate.validator.constraints.NotEmpty;
import org.hibernate.validator.constraints.Range;
import transervfx.Dato.Validacion.ValidacionesNivelLogico;


/**
 *
 * @author oscar
 */
@Entity
//@DiscriminatorValue("F")

@NamedQueries({
    @NamedQuery( name = "Fisico.findAll", query = "SELECT c FROM Fisico c"),
     @NamedQuery( name = "Fisico.findByCuit", query = "SELECT c FROM Fisico c WHERE c.cuit = :cuit"),
    @NamedQuery( name = "Fisico.findByNroDoc", query = "SELECT c FROM Fisico c WHERE c.nroDoc = :nroDoc"),
    @NamedQuery( name = "Fisico.findByTipoDoc", query = "SELECT c FROM Fisico c WHERE c.tipoDoc = :tipoDoc"),
    @NamedQuery( name = "Fisico.findByTipoDocAndNroDoc", query = "SELECT r FROM Fisico r WHERE (r.nroDoc = :nroDoc) AND (r.tipoDoc = :tipoDoc)"),
    @NamedQuery( name = "Fisico.findByNombresAndApellido", query = "SELECT c FROM Fisico c WHERE (c.nombres = :nombres) AND (c.apellido = :apellido)")
    
})
public class Fisico extends Cliente implements Serializable {
    private static final long serialVersionUID = 1L;
    
    
    
    @NotNull(message = "Obligatorio", groups = ValidacionesNivelLogico.class)
    @NotEmpty(message = "Completar", groups = ValidacionesNivelLogico.class)
    @Size(min = 2, max = 30, message = "2 letras minimos, 30 maximo", groups = ValidacionesNivelLogico.class)
    private String nombres;
    
    @NotNull(message = "Obligatorio", groups = ValidacionesNivelLogico.class)
    @NotEmpty(message = "Completar", groups = ValidacionesNivelLogico.class)
    @Size(min = 2, max = 30, message = "2 letras minimos, 30 maximo", groups = ValidacionesNivelLogico.class)
    private String apellido;
    
    @NotEmpty(message = "Obligatorio", groups = ValidacionesNivelLogico.class)
    @Size(min = 2, max = 8, message = "Seleccione uno", groups = ValidacionesNivelLogico.class)
    private String tipoDoc;
    
    @Range(min = 10000000, max = 99999999, message = "8 digitos como minimo y maximo", groups = ValidacionesNivelLogico.class)
    private Integer nroDoc;
    
        //-------------------propiedades binding
    @Transient
    private JavaBeanStringProperty PROP_NOMBRES;
    
    @Transient
    private JavaBeanStringProperty PROP_APELLIDO;
    
    @Transient
    private JavaBeanIntegerProperty PROP_NRODOC;
    
    @Transient
    private JavaBeanStringProperty PROP_TIPODOC;
    

    public Fisico() {
    }
    
    public Fisico(String nombres, String apellido) {
        this.nombres = nombres;
        this.apellido = apellido;
    }

    public String getNombres() {
        return nombres;
    }

    public void setNombres(String nombres) {
        this.nombres = nombres;
    }

    public String getApellido() {
        return apellido;
    }

    public void setApellido(String apellido) {
        this.apellido = apellido;
    }

    public Integer getNroDoc() {
        return nroDoc;
    }

    public void setNroDoc(Integer nroDoc) {
        this.nroDoc = nroDoc;
    }

    public String getTipoDoc() {
        return tipoDoc;
    }

    public void setTipoDoc(String tipoDoc) {
        this.tipoDoc = tipoDoc;
    }

    
     public JavaBeanStringProperty getPROP_NOMBRES() throws NoSuchMethodException {
        if (PROP_NOMBRES == null) {
            PROP_NOMBRES = JavaBeanStringPropertyBuilder.create().bean(this).name("nombres").build();
            getGroupBindProperties().add(PROP_NOMBRES);
        }
        return PROP_NOMBRES;
    }
    
    public JavaBeanStringProperty getPROP_APELLIDO() throws NoSuchMethodException {
        if (PROP_APELLIDO == null) {
            PROP_APELLIDO = JavaBeanStringPropertyBuilder.create().bean(this).name("apellido").build();
            getGroupBindProperties().add(PROP_APELLIDO);
        }
        return PROP_APELLIDO;
    }

    public JavaBeanIntegerProperty getPROP_NRODOC() throws NoSuchMethodException {

        if (PROP_NRODOC == null) {
            PROP_NRODOC = JavaBeanIntegerPropertyBuilder.create().bean(this).name("nroDoc").build();
            getGroupBindProperties().add(PROP_NRODOC);
        }
        return PROP_NRODOC;
    }

    public JavaBeanStringProperty getPROP_TIPODOC() throws NoSuchMethodException {

        if (PROP_TIPODOC == null) {
            PROP_TIPODOC = JavaBeanStringPropertyBuilder.create().bean(this).name("tipoDoc").build();
            getGroupBindProperties().add(PROP_TIPODOC);
        }
        return PROP_TIPODOC;
    }
    
    @Override
    public String toString() {
        return  nombres + " " + apellido ;
    }
    
}
